{% extends 'task-manage/modal-layout.html.twig' %}

{% do script(['libs/ltc-sdk-server.js','libs/jquery-validation.js','libs/iframe-resizer.js','app/js/task-manage/create/index.js']) %}

{% block task_create_type %}
  <div id="task-create-type" class="hidden" data-editor-mode="{{ mode }}" data-course-type="{{ course.type }}"
    {% if mode == 'edit' %}
      data-editor-type="{{ currentType }}"
      data-editor-step2-url="{{ path('course_manage_task_fields', {courseId: course.id, mode: 'edit', id: task.id}) }}"
      data-content-url="{{ path('course_manage_activity_content_modal', {activityId:task.activityId, type: task.type, courseId:course.id}) }}"
      data-finish-url="{{ path('course_manage_activity_finish_modal', {activityId:task.activityId, type: task.type, courseId:course.id}) }}"
      data-save-url="{{ path('course_manage_task_update', {courseId: course.id, id: task.id }) }}"
    {% elseif mode == 'create' %}
      {% if categoryId|default('0') %}
        data-save-url="{{ path('course_manage_task_create', {courseId: course.id}) }}"
      {% else %}
        data-save-url="{{ path('course_manage_lesson_create', {courseId: course.id}) }}"
      {% endif %}
    {% endif %}>
    <form class="form-horizontal" id="step1-form">
      <ul class="form-group task-create-type-list ">
        {% cache courseSet.type ~ '-create-task-activity-metas-' ~ setting('storage.upload_mode', 'local') 1000 %}
          {% for type, meta in activity_metas() if activity_visible(type, courseSet, course) %}
            <li class="col-xs-3 task-create-type-item js-course-tasks-item {% if task.type|default(null)==  type %} active {% endif %}"
                data-role="activityType" data-type="{{ type }}"
                data-content-url="{{ path('course_manage_activity_content_modal', {activityId:0, 'type': type, courseId:course.id}) }}"
                data-finish-url="{{ path('course_manage_activity_finish_modal', {activityId:0, 'type': type, courseId:course.id}) }}">
              <a href="javascript:;" {% if mode=='edit' %} disabled {% endif %}>
                <i class="{{ meta.icon }}"></i>
                {{ meta.name|trans }}
              </a>
            </li>
          {% endfor %}
        {% endcache %}
        <li class="col-xs-12">
          <label for="mediaType" class="hidden">{{'category'|trans}}</label>
          <input name="mediaType" id="mediaType" class="type-hidden">
          <input class="js-hidden-data" type="hidden" name="mode" value="{{ taskMode|default('') }}">
          <input class="js-hidden-data" type="hidden" name="categoryId" value="{{ categoryId|default(null) }}">
          <input class="js-hidden-data" type="hidden" name="fromCourseId" value='{{ course.id }}'>
          <input class="js-hidden-data" type="hidden" name="courseSetType" id="courseSetType" value="{{ courseSet.type }}">
          <input type="hidden" id="courseExpiryMode" value="{{ course.expiryMode }}">
        </li>
      </ul>
    </form>
  </div>
{% endblock %}

{% block task_create_content %}
  <div id="task-create-content"  data-course-id="{{ course.id|default(0) }}" data-activity-id="{{ task.activityId|default(0) }}" class="task-create-content hidden">
    <iframe src="" scrolling="no" class="task-create-content-iframe" id="task-create-content-iframe" name="task-create-content-iframe" frameborder="0"></iframe>
  </div>
{% endblock %}
{% block task_create_finish %}
  <div id="task-create-finish" class="task-create-finish hidden">
    <iframe src="" scrolling="no" class="task-create-finish-iframe" id="task-create-finish-iframe" name="task-create-finish-iframe" frameborder="0"></iframe>
  </div>
{% endblock %}
